package org.zn.mvcbase.exception;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.springframework.http.HttpInputMessage;

/**
 * @ProjectName:zqdk-mvcbase
 * @Description: 
 * @author: 周楠
 * @date 2017年3月6日 下午1:17:47
 */

public class AjaxExceptionResponseRegister  extends AbstractExceptionResponseRegister{
	

	public AjaxExceptionResponseRegister() {
		super();
	}
	public AjaxExceptionResponseRegister(Integer order){
		super(order);
	}
	
	@Override
	public Class<? extends ExceptionResponseState> getExceptionResponseStateType(
			HttpInputMessage httpInputMessage) {
		
		Class<? extends ExceptionResponseState>  returnclass=null;
		
		
		 List<String>  xrw =httpInputMessage.getHeaders().get("X-Requested-With");
		 
		 
		 if(xrw==null||xrw.size()==0) {
			 xrw=httpInputMessage.getHeaders().get("x-requested-with");
		 }
		 
		 
		 if(xrw!=null&&xrw.size()>0&&xrw.contains("XMLHttpRequest")){
			 
			 returnclass=AjaxExceptionResponseState.class;
			 
		 }
		 
		return returnclass;
	}
	
}
